package file1;

import java.io.File;
import java.io.FileFilter;

public class Test06 {
    public static void main(String[] args) {
        File dir=new File(".");
        /*if (file.isDirectory()){
            File[] subs=file.listFiles();
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }*/
       /* if (dir.isDirectory()){
            File[] subs=dir.listFiles(new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name=file.getName();
                    return name.endsWith(".txt");
                }
            });
            File[] subs=dir.listFiles(filter);
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }*/

        if (dir.isDirectory()){
            File[] subs=dir.listFiles(file-> file.getName().endsWith(".txt"));
            for (File file:subs){
                System.out.println(file.getName());
            }
        }

    }
}
